package com.wskj.workbench.enums;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.wskj.common.enums.BaseEnum;
import lombok.Getter;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;


/**
* Filename: SysUserUserTypeEnum.java
* Description: 用户类型枚举类
* Copyright: Copyright (c) 2016-2019 All Rights Reserved. 
* Company: wsdz.com Inc.
*
* @author: guqk
* @version: 1.0 
* Create at: 2022/8/16 14:15 
*
* Modification History: 
* Date Author Version Description 
* ------------------------------------------------------------------ 
* 2022/8/16 guqk 1.0 1.0 Version 
*/
@Getter
public enum SysUserUserTypeEnum implements BaseEnum<String> {
    /** 00-系统用户 */
    SYSTEM_USER("00","系统用户"),
    /** 01-主播 */
    GENERAL_USER("01","主播"),
    /** 02-团长 */
    ON_DOCTOR("02","团长"),
    /** 03-分公司 */
    ORGANIZATION("03","分公司")
    ;

    @EnumValue
    private String value;

    private String desc;

    SysUserUserTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator
    public static SysUserUserTypeEnum parse(String param) {
        if (Objects.isNull(param)) {
            return null;
        }
        for (SysUserUserTypeEnum item : SysUserUserTypeEnum.values()) {
            if (item.value.equals(param) || item.name().equals(param)) {
                return item;
            }
        }
        return null;
    }

    @JsonValue
    @Override
    public String toString() {
        Map<String,Object> map = new LinkedHashMap<>(2);
        map.put("value",this.value);
        map.put("desc",this.desc);
        String jsonString = JSONUtil.toJsonStr(map);
        return jsonString;
    }
}
